export const DEFAULT_INTERVAL = 3 * 1000
export enum AccessEnum {
  ADMIN = 'ADMIN',
  USER = 'USER',
}

export enum DynamicLoadEnum {
  FRONTEND = 'FRONTEND', // 前端动态加载菜单，使用这种方式将从dynamic-routes.ts中加载菜单和路由信息
  BACKEND = 'BACKEND', // 后端动态加载菜单， 使用这种方式将从后端接口加载菜单和路由信息
}

// 路由加载方式（默认情况下我们提供从后端加载的逻辑）
export const DYNAMIC_LOAD_WAY = import.meta.env.VITE_APP_LOAD_ROUTE_WAY ?? DynamicLoadEnum.BACKEND

export interface Options {
  value: number | string | boolean
  label: any
}

export const TRUE_FALSE_OPTIONS = [
  { value: true, label: '是' },
  { value: false, label: '否' },
]

export const ENABLE_OPTIONS = [
  { value: true, label: '有效' },
  { value: false, label: '无效' },
]

export function getOptionLabel(options: Options[], value: string | number | boolean) {
  return options?.find(item => item.value === value)?.label ?? value
}

/* -------corn相关 start-------- */
export const dataOptions = (count = 10, start = 0) => {
  return new Array(count).fill({}).map((_, idx) => ({ value: idx + start, label: `${idx + start}`.padStart(2, '0') }))
}
export const secondOptions = dataOptions(60)
export const minuteOptions = secondOptions
export const hourOptions = dataOptions(24)
export const dayOptions = dataOptions(31, 1)
export const monthOptions = dataOptions(12, 1)
export const weekOptions = [
  { value: 1, label: '周日' },
  { value: 2, label: '周一' },
  { value: 3, label: '周二' },
  { value: 4, label: '周三' },
  { value: 5, label: '周四' },
  { value: 6, label: '周五' },
  { value: 7, label: '周六' },
]
/* -------corn相关 end-------- */
